<%@ include file="/framework/purehead.jsp"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="com.hitrust.gs.util.AESCoder" %>
<LINK href="<%=Config.getWebPath()%>/css/css.css" rel="stylesheet" type="text/css">
<%
ObjectList tList = MenuInfo.fetchbyParentCode(con);
ObjectList tSubList = MenuInfo.fetchSubs(con);
%>
<script language="JavaScript1.2">
  var isHidden = false;
function process() {
  if (isHidden) {
      document.getElementById("menulist").style.display="";
      isHidden = false;
  }
  else { 
    document.getElementById("menulist").style.display="none";  
    isHidden = true;
  }
  top.switchSysBar();
}
  function   clickColor(x){   
  for(i=0;i<h.length;i++){   
    h[i].color="";
    h[x].color="#990066";
  }   
  } 
//-->
</script>  
<table width="178" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td id="menulist">
    <table width="164" height="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="164" valign="top">
    <%
    if(tList.size()>0){
        int nums = 0;
        String curUserId = loginInfo.getLoginUserId();
        ObjectList list = UserMenuinfo.fetchbyUserId(curUserId,con);
        int a = 0;
        for(int i=0;i<tList.size();i++){
            MenuInfo mi = (MenuInfo)tList.get(i);
            //ObjectList mList = MenuInfo.fetchbyCode(mi.getMenuCode(),con);
            ObjectList mList = MenuInfo.getListSubByParentCode(tSubList,mi.getMenuCode());
            boolean isExist  = false;
            if(list.size()>0){
                for(int k=0;k<list.size();k++){
                    UserMenuinfo umi = (UserMenuinfo)list.get(k);
                    //MenuInfo mi1 = MenuInfo.fetch(con,umi.getMenuId());
                    MenuInfo mi1 = MenuInfo.getListSubById(tSubList,umi.getMenuId());
                    if(mi1 != null){
                        if(mi1.getParentCode() ==mi.getMenuCode()&&mi1.getMenuCode()!=ConstDefine.VIEW_SWITCH){
                            isExist = true;
                            nums++;
                            break;

                        }
                    }
                    
                }
            }
            if(isExist){
                if(nums==1) {%>
                    <td id="Pan<%=nums%>" width="164" height="268" valign="top" bgcolor="C5CBD2" class="css1">
                <%}else{
                    %>
                    <td id="Pan<%=nums%>" width="164" height="268" valign="top" bgcolor="C5CBD2" class="css1" style="display:none">
                    <%
                }
                %>
                <table width="164" border="0" cellspacing="0" cellpadding="0">
                    <tr><td height="5" colspan="3">&nbsp;</td></tr>
                <%if(mList.size()>0){
                    for(int j=0;j<mList.size();j++){
                        MenuInfo mi2 = (MenuInfo)mList.get(j);
    
                        if(list.size()>0){
                            for(int k=0;k<list.size();k++){
                                UserMenuinfo umi = (UserMenuinfo)list.get(k);                                
                                if(umi.getMenuId().equals(mi2.getId())&&mi2.getMenuCode()!=ConstDefine.VIEW_SWITCH){                                  
                                    %>
                                    <tr>
                                         <td width="5%">&nbsp;</td><td width="8%"><img src="<%=Config.getWebPath()%>/images/bar_small.gif"></td>
                                         <%
                                         String url=Config.getWebPath();
                                         if(mi2.getUrl().indexOf(".do")!=-1){
                                             url+="/"+mi2.getUrl();
                                         }else{
                                             if(mi2.getUrl().indexOf("listProduct")!=-1){//产品查询附加仓库信息查询条件
                                                 url+="/servlet/Srv"+mi2.getUrl() + "&s_WarehouseCode=00|" + loginInfo.getLoginWarehouseCode();    
                                             }
                                             else if(mi2.getUrl().indexOf("listTempProduct")!=-1){//临时产品查询附加仓库信息查询条件
                                                 url+="/servlet/Srv"+mi2.getUrl() + "&s_WarehouseCode=00|" + loginInfo.getLoginWarehouseCode();    
                                             }
                                             else if(mi2.getUrl().startsWith("http:")){
                                            	 String loginCode=loginInfo.getUser().getCode();
                                            	 String pwd=loginInfo.getUser().getPassword();
                                            	 String aeskey=Config.getAesKey();
                                         		 System.out.println("KEY:\t" + aeskey);
                                            	 AESCoder desCoder = new AESCoder();
                                         		 String code = desCoder.encrypt(loginCode, aeskey);	
                                           		 System.out.println("code:\t" + code);
                                         		 String password = desCoder.encrypt(pwd, aeskey);	
                                         		 System.out.println("password:\t" + password);
                                         		 
                                            	 url=mi2.getUrl()+ "?warehouseCode=" + loginInfo.getLoginWarehouseCode()+"&user.code="+code+"&user.password="+password;  
                                            	 System.out.println("url:\t" + url);
                                             }
                                             else{
                                                 url+="/servlet/Srv"+mi2.getUrl();
                                             }    
                                         }
                                         %>
                                         <td height="20"><a href="<%=url %>" target="main"><STRONG><font id="h"  onClick="clickColor('<%=a%>');"><%=mi2.getMenuName()%></font></STRONG></a></td>
                                    </tr>            
                                    <%
                                    a++;
                                }
                            }
                        }
                    }
                }
                %>
                </table>  
                        </td>
                <%
            }
        }
    }
    %>
    </td>
    </tr>
    </table>
    </td>
    <td width="16" align="center" valign="middle" background="<%=Config.getWebPath()%>/images/bar_bg.gif"><img src="<%=Config.getWebPath()%>/images/bar_button.gif" width="16"   onclick="process()"></td>
  </tr>
</table>
<%@ include file="/framework/purefoot.jsp"%>